PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Defining a Subroutine With Labeled Parameters

The definition for a subroutine with labeled parameters lists the labels to use when calling the subroutine and the statements to be executed when it is called.

SYNTAX
( on | to ) subroutineName                                      ¬
            [ [ of | in ] directParameterVariable ]            ¬
            [ subroutineParamLabel paramVariable ]...           ¬
            [ given label:paramVariable [, label:paramVariable ]...]
    [ global variable [, variable ]...]
    [ local variable [, variable ]...]
    [ statement ]...        
end [ subroutineName ]

where

subroutineName (an identifier) is the subroutine name.

directParameterVariable (an identifier) is a parameter variable (also called a formal parameter) that represents the actual value of the direct parameter. You use this identifier to refer to the direct parameter in the body of the subroutine definition. As with application commands, the direct parameter must be first.

Note

If a subroutine includes a direct parameter, the subroutine must also include either the subroutineParamLabel parameter or the given label : paramVariable parameter.

subroutineParamLabel is one of the following labels: about , above , against , apart from, around , aside from , at , below , beneath , beside , between , by , for , from , instead of , into , on , onto , out of , over , since , thru (or through ), under . These labels are the only labels that can be used without the special label given . As in other commands, each label must be unique among the labels for the subroutine (that is, you cannot use the same label for more than one parameter).

paramVariable (an identifier) is a parameter variable for the actual value of a parameter. You use this identifier to refer to the parameter in the body of the subroutine.

label is any parameter label. This can be any valid AppleScript identifier. You must use the special label given to specify parameters whose labels are not among the labels for subroutineParamLabel .

variable is an identifier for either a global or local variable that can be used in the handler. The scope of a local variable is the handler. The scope of a global variable can extend to any other part of the script, including other handlers and script objects. For detailed information about the scope of local and global variables, see Scope of Script Variables and Properties.

statement is any AppleScript statement.

NOTES

For more information, see Examples of Subroutines With Labeled Parameters.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)